package com.mayikt;

/**
 * @ClassName Test014
 * @Author 蚂蚁课堂余胜军 QQ644064779 www.mayikt.com
 * @Version V1.0
 **/
public class Test014 {
    private static Object lock = new Object();

    public static void main(String[] args) {
        new Thread(() -> {
            synchronized (lock) {
                try {
                    // 释放锁，同时释放cpu执行权
                    System.out.println("1");
                    lock.wait();
                    System.out.println("2");
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }

        }).start();
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("3");
        synchronized (lock) {
            // 唤醒子线程
            lock.notify();
        }


    }
}
